package utils

import (
	"io/ioutil"
	"log"

	yaml "gopkg.in/yaml.v2"
)

type MysqlConfig struct {
	Type     string `yaml:"type"`
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	User     string `yaml:"user"`
	Password string `yaml:"password"`
	Database string `yaml:"database"`
	Charset  string `yaml:"charset"`
}

func GetMysqlConfig() (settings *MysqlConfig, err error) {
	yamlFile, err := ioutil.ReadFile(RootPath + "/config/mysql.yaml")
	if err != nil {
		log.Fatalf("mysql.yaml get err #%v", err)
	}
	err = yaml.Unmarshal(yamlFile, &settings)
	return settings, err
}
